/*
Copyright (C) 2015 Jochem Raat

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

class WindMapGenerator {
public:
    // The constructor
    WindMapGenerator();

    // Generate a wind map for the give surface height map with the
    // given width and length. A pointer to the wind map will be
    // returned, which is represented as an array of doubles of length
    // (width * height). All values are between 0 and 1. The higher
    // the value, the stronger the wind.
    double *generateWindMap(
        // The height map to base the wind map on
        double *surfaceHeightMap,

        // The width and height of the maps
        unsigned width,
        unsigned height);

private:
    // Generate one row of the wind map with a pointer to the row of
    // the surface height map and the wind map to input the
    // values in.
    void generateWindRow(
        double *surfaceHeightRow,
        double *outputRow,
        unsigned width);

    // Return the `speed' adjusted for a ridge which is `height'
    // higher than the current place and `distance' to the left.
    double adjustSpeed(
        int distance,
        double height,
        double speed);

    // The initial wind speed
    double startSpeed = 1;

    // Between 0 and 1, higher makes the height have less of an impact
    double heightAdjustment = 0.6;

    // Between 0 and 1, lower makes the distance have less of an
    // impact
    double distanceAdjustment = 0.5;
};
